package com.lph.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lph.dao.MenberDaoI;
import com.lph.model.BaseClass;
import com.lph.util.HighChartUtil;

@Service
public class ReportService {
	@Autowired
	private MenberDaoI mdi;
	
	public String getPieData(){
		//利用baseclass的dou存放性别的比例
		String title="会员性别比例图例";
		List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
		List<BaseClass> datas=mdi.selectSexConut();
		for(int i=0;i<datas.size();i++){
			BaseClass bc=datas.get(i);
			Map<String, Object> m1=new HashMap<String, Object>();
			m1.put("name", bc.getSex());
			m1.put("y", bc.getDou()*100);
			if(i==1){
				m1.put("sliced", true);
				m1.put("selected", true);
			}
			list.add(m1);
			}
		return HighChartUtil.getPie(title, list);
	}
	public String getColumn(String type){
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		String title = "月平均降雨量";
		String subtitle = "数据来源: WorldClimate.com";
		String y = "降雨量 (mm)";
		
		String x[] = {"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
		
		
		Map<String, Object> m1 = new HashMap<String, Object>();
		m1.put("name", "东京");
		
		double bs[] = {49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4};
		
		m1.put("data", bs);
		list.add(m1);
		
		return HighChartUtil.getColumn(title, subtitle, y, x, list,type);
	}
}
